#include "ConfigHelper.h"

#include <QSettings>

ConfigHelper*ConfigHelper::configHelper=NULL;
ConfigHelper::ConfigHelper(QObject *parent) : QObject(parent)
{/*
    if(ConfigHelper::Current == NULL)
    {
        ConfigHelper::Current = new ConfigHelper;
    }
    ConfigHelper::Current->LoadSettings("config.ini");*/
}

QVariant ConfigHelper::GetSettingValue(QString key)
{
    return setting->value(key);
}

void ConfigHelper::SetSettingValue(QString key, QString value)
{
    setting->setValue(key,value);
}

ConfigHelper *ConfigHelper::getInstance()
{
    if(configHelper==NULL)
    {
        configHelper=new ConfigHelper;
    }
    configHelper->LoadSettings("config.ini");
    return configHelper;
}

QString ConfigHelper::GetSaveFolder()
{
    return this->GetSettingValue("/Program/WallpaperSaveFolder").toString();
}

void ConfigHelper::SetSaveFolder(QString dir)
{
    setting->setValue("/Program/WallpaperSaveFolder",dir);
}


void ConfigHelper::LoadSettings(QString filename)
{
    setting = new QSettings(filename,QSettings::IniFormat);
}



